package cn.liulin.java8.stream;

import java.util.Arrays;
import java.util.List;

/**
 * cn.liulin.java8.stream$
 *
 * @author ll
 * @date 2021-10-14 13:32:28
 **/
public class StreamReduce {
    public static void main(String[] args) {
//        reduceOne();
        reduceTwo();
    }

    private static void reduceTwo() {
        List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6, 6);
        Integer integer = integers.stream().reduce(Integer::max).get();
        System.out.println(integer);
    }

    private static void reduceOne() {
        List<Integer> integers = Arrays.asList(1, 2, 3, 4, 5, 6);
//        Integer reduce = integers.stream().reduce(0, (x1, x2) -> x1 + x2);
        Integer reduce = integers.stream().reduce(0, Integer::sum);
        System.out.println(reduce);
    }
}
